package com.ccut.xunfeiSpringboot.controller;

import com.ccut.xunfeiSpringboot.common.AjaxResult;
import com.ccut.xunfeiSpringboot.dto.KnowledgeGraphDTO;
import com.ccut.xunfeiSpringboot.service.KnowledgeGraphService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.net.MalformedURLException;
import java.security.SignatureException;
import java.util.Map;

@RestController
@RequestMapping("/knowledgeGraph")
@Slf4j
public class KnowledgeGraphController {

    @Autowired
    private KnowledgeGraphService knowledgeGraphService;

    @PostMapping("/getNodesAndLinksByAI")
    public AjaxResult getNodesAndLinksByAI(@RequestBody Map<String, String> payload) throws Exception {
        String prompt = payload.get("data");
        String userId = payload.get("userId");
        KnowledgeGraphDTO nodesAndLinksByAI = knowledgeGraphService.getNodesAndLinksByAI(prompt, Integer.valueOf(userId));
        return AjaxResult.success(nodesAndLinksByAI);
    }
}
